home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / freeWAIS-sf-1.1 / ctype / mkctype.c < prev    next >
C/C++ Source or Header  |  1994-12-05  |  5KB  |  182 lines

  1. /*                               -*- Mode: C -*- 
  2.  * mkctype.c -- 
  3.  * ITIID           : $ITI$ $Header $__Header$
  4.  * Author          : Ulrich Pfeifer
  5.  * Created On      : Wed Mar 23 09:45:04 1994
  6.  * Last Modified By: Ulrich Pfeifer
  7.  * Last Modified On: Tue Dec  6 17:25:28 1994
  8.  * Update Count    : 45
  9.  * Status          : Unknown, Use with caution!
  10.  */
  11.  
  12. /* HISTORY 
  13.  * 22-Jul-1994        Ulrich Pfeifer    
  14.  *    Last Modified: Fri Jul 22 14:33:16 1994 #39 (Ulrich Pfeifer)
  15.  *    Moved str*cmp* stuff to ctype.tmpl
  16.  */
  17.  
  18. #include "../ir/cdialect.h"
  19.  
  20. #include <ctype.h>
  21. #include <stdio.h>
  22. #ifndef LCHARS
  23. #define LCHARS "Σ÷ⁿ▀"
  24. #endif
  25. #ifndef UCHARS
  26. #define UCHARS "─╓▄▀"
  27. #endif
  28. #ifndef CTYPEVAR
  29. unsigned char _ctype_[]=  {
  30. 0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x28,0x28,0x28,0x28,0x28,0x20,
  31. 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
  32. 0x20,0x88,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
  33. 0x10,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x10,0x10,0x10,0x10,0x10,
  34. 0x10,0x10,0x41,0x41,0x41,0x41,0x41,0x41,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  35. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x10,0x10,0x10,0x10,
  36. 0x10,0x10,0x42,0x42,0x42,0x42,0x42,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
  37. 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x10,0x10,0x10,0x10,
  38. 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  39. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  40. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  41. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  42. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  43. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  44. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  45. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  46. };
  47.  
  48.  
  49. #ifdef _U
  50. #undef _U
  51. #endif
  52. #define _U    0x01
  53. #ifdef _L
  54. #undef _L
  55. #endif
  56. #define _L    0x02
  57. #ifdef _N
  58. #undef _N
  59. #endif
  60. #define _N    0x04
  61. #ifdef _S
  62. #undef _S
  63. #endif
  64. #define _S    0x08
  65. #ifdef _P
  66. #undef _P
  67. #endif
  68. #define _P    0x10
  69. #ifdef _C
  70. #undef _C
  71. #endif
  72. #define _C    0x20
  73. #ifdef _X
  74. #undef _X
  75. #endif
  76. #define _X    0x40
  77. #ifdef _B
  78. #undef _B
  79. #endif
  80. #define _B    0x80
  81.  
  82. #define CTYPEVAR _ctype_
  83. #endif /* CTYPEVAR */
  84.  
  85. unsigned char ctype[256];
  86. unsigned char tToUP[256]; /* char of the ones converted toupper by our INTL mcaro */
  87. unsigned char tToLOW[256]; /* char of the ones converted tolower by our INTL mcaro */
  88.  
  89. /* This is a copy from the funtion in ../ir/cutil.c :( */
  90. #ifdef NEED_MYBCOPY
  91. void
  92. mybcopy(b1, b2, length)
  93.      char *b1, *b2;
  94.      int length;
  95. {
  96.   int i;
  97.   if (b1 > b2) {
  98.     for (i=0;i<length;i++) {
  99.       b2[i] = b1[i];
  100.     }
  101.   } else {
  102.     for (i=length-1;i>=0;i--) {
  103.       b2[i] = b1[i];
  104.     }
  105.   }
  106. }
  107. #endif /* NEED_MYBCOPY */
  108.  
  109. main()
  110. {
  111.   int i,j;
  112.   unsigned char *s;
  113.  
  114.   /* extern void bcopy(); */
  115.   bcopy(CTYPEVAR,ctype,256*sizeof(char)); 
  116.  
  117.   printf("unsigned char _lchars_[] = \"%s\";\n", LCHARS);
  118.   printf("unsigned char _uchars_[] = \"%s\";\n", UCHARS);
  119.   for(s=(unsigned char*)LCHARS;*s;s++) {
  120.    /* why do you shift all by one in ctype ? MN */
  121.     ctype[*s+1] |= _L;
  122.     ctype[*s+1] &= ~(_S|_N|_P);
  123.     fprintf(stderr, "_ctype[%d]=%d\n", *s+1,ctype[*s+1]);
  124.   }
  125.   for(s=(unsigned char*)UCHARS;*s;s++) {
  126.     ctype[*s+1] |= _U;
  127.     ctype[*s+1] &= ~(_S|_N|_P);
  128.     fprintf(stderr, "_ctype[%d]=%d\n", *s+1,ctype[*s+1]);
  129.   }
  130.   printf("unsigned\n#ifdef STDC_HEADERS\nconst\n#endif\nchar _fw_ctype_[]=  {\n");
  131.   for (i=0;i<16;i++) {
  132.     for (j=0;j<16;j++) {
  133.       printf("0x%02x,", ctype[i*16+j]);
  134.     }
  135.     printf("\n");
  136.   }
  137.   printf("};\n");
  138.   /* MN addition */  
  139.   /* identity transform ... I know too many ops - but simple and done only once */
  140.   for( i=0; i<256; i++)
  141.     tToUP[i] = tToLOW[i] = (unsigned char)i;
  142.   
  143.   for( i=0; i <= ('Z'-'A'); i++){ /* 7bit ASCII toupper/lower lookup table */
  144.     tToLOW[(int)(i+'A')] = i + 'a'; 
  145.     tToUP[(int)(i+'a')] = i + 'A';
  146.     }
  147.   {unsigned char *pLowChars, *pUpChars;
  148.    for( pLowChars = (unsigned char*)LCHARS, pUpChars = (unsigned char*)UCHARS;
  149.        *pLowChars && *pUpChars; pLowChars++, pUpChars++ ){
  150.      
  151.      tToLOW[ *pUpChars ] = *pLowChars; /* remember the next tolower conversion item */
  152.      tToUP[ *pLowChars ] = *pUpChars;  /* remember the next toupper conversion item */
  153.    }
  154.  }
  155.  
  156.   printf("\n#ifndef STDC_HEADERS\n");
  157.   printf("#define INTL_CTYPE_MODULE  \n");
  158.   printf("unsigned char tToUP[]=  {\n");
  159.   for (i=0;i<16;i++) {
  160.     for (j=0;j<16;j++) {
  161.       printf("0x%02x,", tToUP[i*16+j]);
  162.     }
  163.     printf("\n");
  164.   }
  165.   printf("};\n");
  166.  
  167.   printf("unsigned char tToLOW[]=  {\n");
  168.   for (i=0;i<16;i++) {
  169.     for (j=0;j<16;j++) {
  170.       printf("0x%02x,", tToLOW[i*16+j]);
  171.     }
  172.     printf("\n");
  173.   }
  174.   printf("};\n");
  175.   
  176.   printf("#endif\n");
  177. /*  MN */
  178.  
  179.  
  180.   exit(0);
  181. }
  182.